<?xml version="1.0" encoding="utf-8"?>

<!-- Assignment 1 -->
<!-- Name: Piyush Garg -->
<!-- StudentID: S3218012 -->
<!-- medicare.xsd -->
<!-- Document MarkUp Language -->

<!-- This DTD document is the Medicare System containing all the details -->

<!-- schema element required as its starting element -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.w3schools.com"
	xmlns="http://www.w3schools.com"
	elementFormDefault="qualified">

<!-- Root Element Medicare with its child element as Medicare Details-->

  <xs:element name="Medicare">
    <xs:complexType>
      <xs:sequence minOccurs="1" maxOccurs="unbounded">
        <xs:element ref="MedicareDetails" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

<!-- Child elements of Medicare Details as CardInfo, PersonInfo -->

  <xs:element name="MedicareDetails">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="CardInfo" />
        <xs:element ref="PersonInfo" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

<!-- CardInfo Details  -->

  <xs:element name="CardInfo">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="CardID" />
        <xs:element ref="CardType" />
        <xs:element ref="ExpiryDate" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

<!-- Each Card is Unique and can not be replicated -->

  <xs:element name="CardID">
    <xs:complexType>
      <xs:attribute name="id" type="xs:ID" use="required" />
    </xs:complexType>
  </xs:element>

<!-- Each Card can be either Reciprocal or Interm -->

  <xs:element name="CardType">
    <xs:complexType>
      <xs:attribute default="Reciprocal" name="type">
        <xs:simpleType>
          <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="Reciprocal" />
            <xs:enumeration value="Interm" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  <xs:element name="ExpiryDate" type="xs:date" />

<!-- Each Card can be assigned upto 9 people -->

  <xs:element name="PersonInfo">
    <xs:complexType>
      <xs:sequence minOccurs="1" maxOccurs="9">
        <xs:element ref="Person" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Person">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="PersonalInformation" />
        <xs:element ref="MedicalInformation" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

<!-- Each Card Member is identified on the basis of their name,Gender,DOB,ContactInformation -->

  <xs:element name="PersonalInformation">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Name" />
        <xs:element ref="Gender" />
        <xs:element ref="DOB" />
        <xs:element ref="ContactInformation" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Name">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="FirstName" />
        <xs:element ref="LastName" />

	<!-- Middle name is Optional to enter-->

        <xs:element minOccurs="0" maxOccurs="1" ref="MiddleName" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

<!-- Defining the types of elements in Name Elements and its sub elements -->

  <xs:element name="FirstName" type="xs:string" />
  <xs:element name="LastName" type="xs:string" />
  <xs:element name="MiddleName" type="xs:string" />
  <xs:element name="Gender">
    <xs:complexType>
      <xs:attribute default="Male" name="sex">
        <xs:simpleType>
          <xs:restriction base="xs:NMTOKEN">

	       <!-- Have only two types of values Maale and Female that is expressed as enumeration-->
	
	     <xs:enumeration value="Male" />
            <xs:enumeration value="Female" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  <xs:element name="DOB" type="xs:date" />

<!-- Each Member is provided with a choice of their prefferred contact whether Telephone or Email -->
<!-- Choice of Contact decided on its boolean value -->

  <xs:element name="ContactInformation">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="MailAddress" />
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="Telephone" />
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="Email" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

<!-- Defining the types of elements in MailAddress Elements and its sub elements -->

  <xs:element name="MailAddress">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Street" />
        <xs:element ref="City" />
        <xs:element ref="State" />
        <xs:element ref="ZipCode" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Street" type="xs:string" />
  <xs:element name="City" type="xs:string" />
  <xs:element name="State" type="xs:string" />

<!-- The zip code must be 4 digit long -->

  <xs:element name="ZipCode" >
    <xs:simpleType>
      <xs:restriction base="xs:integer">

	<!-- The zip code must follow this pattern -->

        <xs:pattern value="[0-9][0-9][0-9][0-9]" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>

<!-- Each Member is provided with a choice of their prefferred contact whether Telephone or Email -->

  <xs:element name="Telephone">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:integer">
          <xs:attribute default="false" name="prefferred">
            <xs:simpleType>
              <xs:restriction base="xs:NMTOKEN">
		
		  <!-- Choice of Contact decided on its boolean value -->

                <xs:enumeration value="true" />
                <xs:enumeration value="false" />
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

<!-- Each Member is provided with a choice of their prefferred contact whether Telephone or Email -->
<!-- Choice of Contact decided on its boolean value -->

  <xs:element name="Email">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute default="false" name="prefferred">
            <xs:simpleType>
              <xs:restriction base="xs:NMTOKEN">

		  <!-- Choice of Contact decided on its boolean value -->

                <xs:enumeration value="true" />
                <xs:enumeration value="false" />
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

<!-- Each Card Member is asked to enter their medical Details such as Blood Type, Illness, Allergy -->

  <xs:element name="MedicalInformation">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="BloodType" />
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="AllergyInformation" />
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="ChronicIllness" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="BloodType">
    <xs:complexType>

     <!-- The member blood type is set to OPositive by default -->

      <xs:attribute default="OPositive" name="btype">
        <xs:simpleType>

	  <!-- The user have to select any one of them -->

          <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="OPositive" />
            <xs:enumeration value="APositive" />
            <xs:enumeration value="BPositive" />
            <xs:enumeration value="ONegative" />
            <xs:enumeration value="ABPositive" />
            <xs:enumeration value="ANegative" />
            <xs:enumeration value="BNegative" />
            <xs:enumeration value="ABNegative" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  <xs:element name="AllergyInformation" type="xs:string" />
  <xs:element name="ChronicIllness" type="xs:string" />
</xs:schema>

<!-- This is the end of the document listing with all the elements that are required in Medicard System -->

